import api from '../index'

export default {
  // 登录
  login: (data: LoginBody) => api.post<UserLoginInfo>('admin/login', data),

  logout: () => api.get('admin/logout', {
    baseURL: '/mock/',
  }),

  // 修改密码
  passwordEdit: (data: EditPasswordBody) => api.post('admin/updatePwd', data, {
    baseURL: '/mock/',
  }),

  add: (data: AddUserApiTypes) => api.post('admin', data),

  edit: (data: AddUserApiTypes) => api.put<Resp<number>>('admin', data),

  delete: (id: number) => api.delete(`admin/${id}`),

  getList: (data: PageQuery) => api.post<Page<UserApiTypes>>('adminList', {}, {
    params: data,
  }),

  getById: (id: number) => api.get<UserApiTypes>(`admin/${id}`),
}
